Providers
Providers connect BindAI agents to language models. BindAI separates agent configuration from the underlying model provider so applications can select different model providers without changing the overall agent architecture. The provider layer handles provider-specific model integration while the agent layer provides a consistent application-facing interface.Provider Architecture
The relationship between an application, agent, provider, and model can be represented as:Supported Providers
The current BindAI provider ecosystem includes:- OpenAI
- Anthropic
- Google Gemini
- Groq
- Ollama
- OpenRouter
Configuring a Model
The recommended way to select a model is throughAgent.builder().
Provider-Qualified Models
Provider-qualified model names allow the application to select a provider and model through a single configuration value. For example:Environment Variables
Provider credentials should not be hardcoded into application source code. For example:OpenAI
OpenAI models can be selected using theopenai provider prefix.
Anthropic
Anthropic models can be selected using theanthropic provider prefix.
Google Gemini
Google Gemini models can be selected using thegoogle provider prefix.
Groq
Groq models can be selected using thegroq provider prefix.
Ollama
Ollama models can be selected through theollama provider prefix.
OpenRouter
OpenRouter models can be selected through theopenrouter provider prefix.
Provider Registry
BindAI maintains a provider registry for supported provider implementations. The registry can expose the names of registered providers:Provider Bootstrap
BindAI initializes supported provider integrations through provider bootstrap. The CLI initializes the provider ecosystem before running the application. Conceptually:Provider and Agent Configuration
Provider configuration and agent behavior are separate concerns. For example:model()selects the provider and model.instructions()defines agent behavior.build()creates the configured agent.
Switching Providers
Because the model is configured through the agent builder, changing providers can often be as simple as changing the model string. For example:Provider and Tools
Providers work together with BindAI’s tool system. For example:Provider and Structured Output
BindAI agents can request structured output throughrun().
For example:
Provider and Streaming
BindAI exposes streaming APIs for agent execution. For conversational streaming:- Chat interfaces
- Interactive applications
- Long responses
- Real-time user experiences
Provider and Memory
Memory is implemented at the BindAI agent/application layer rather than being tied to a particular model provider. For example:Provider and Knowledge
Knowledge and retrieval are also separate from the provider implementation. For example:Local Models
One advantage of the provider abstraction is that applications can use local inference services. For example:Custom Providers
BindAI exposes provider abstractions that allow additional provider implementations to be integrated into the framework. The provider ecosystem is designed around common provider interfaces and registration. Custom provider implementations should follow the provider interfaces exposed by the BindAI version being used. Because provider APIs can evolve independently, consult the provider implementation and API reference when developing a custom integration.Provider Independence
Provider independence means that the application-level agent interface is separated from provider-specific model communication. For example, the application can construct an agent using:Provider Portability
The provider-qualified model format allows the same general agent architecture to be used with different providers. For example:- Tool calling
- Structured output
- Streaming
- Particular context limits
- Provider-specific features
Choosing a Provider
The appropriate provider depends on the application’s requirements. Consider:- Model capabilities
- Hosting requirements
- Privacy requirements
- Latency
- Cost
- Tool-calling support
- Structured-output support
- Streaming support
- Deployment environment
- Local versus hosted inference
Provider Configuration in Development
A typical development environment can keep provider credentials in a.env file.
For example:
.env file when it contains real credentials.
A project can also configure only the provider credentials it actually needs.
Provider Errors
Provider execution can fail for reasons such as:- Invalid credentials
- Missing credentials
- Unsupported model
- Provider service errors
- Network failures
- Rate limits
- Invalid requests
- Insufficient provider account credits
AgentResult returned by agent execution to determine whether an execution succeeded.
For example:
Provider Testing
Provider integrations should be tested independently as well as through agent execution. Useful tests include:- Provider registration
- Provider discovery
- Model creation
- Authentication configuration
- Tool calling
- Structured output
- Streaming
- Error handling
Complete Example
A complete agent can use the provider abstraction together with other BindAI capabilities:Best Practices
- Keep provider credentials out of source code.
- Use environment variables or an appropriate secret-management system for credentials.
- Use the
provider:modelformat when selecting a model. - Prefer
Agent.builder()for agent configuration. - Keep provider-specific logic out of application-level business logic where practical.
- Verify model capabilities before relying on tool calling or structured output.
- Test provider/model combinations used by the application.
- Use local providers when local inference is appropriate.
- Choose models based on the actual requirements of the task.
- Keep provider configuration separate from agent instructions whenever possible.
- Do not assume that different providers will produce identical behavior.
- Keep provider integrations modular so additional providers can be added without changing the core agent abstraction.
